package com.example.mapp;

import com.example.entity.authority.SystemRoleType;
import com.example.ext.entity.ExtSystemRole;
import com.example.mapp.buildSql.SysUserMappSql;
import com.example.mapp.buildSql.SystemRoleTypeMappSql;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by youkun on 2018/3/16.
 * 角色类型
 */
@Mapper
public interface SystemRoleTypeMapp {

    @SelectProvider(
            type = SystemRoleTypeMappSql.class,
            method = "queryList")
    List<SystemRoleType> queryList(SystemRoleType systemRoleType);

    @Insert(" insert into system_role_type (role_type_name,role_type_describe) value (#{roleTypeName},#{roleTypeDescribe})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    public int add(SystemRoleType systemRoleType) throws Exception;

    @Update(" update system_role_type set role_type_name =#{roleTypeName},role_type_describe =#{roleTypeDescribe} where id=#{id}")
    public int update(SystemRoleType systemRoleType) throws Exception;

    @Delete(" delete from system_role_type where id=#{id} ")
    public int deleteById(String id) throws Exception;

    @Select("select * from system_role_type where role_type_name =#{roleTypeName}")
    SystemRoleType queryByRoleTypeName(String roleTypeName)throws Exception;

    @Select("select * from system_role_type where id =#{id}")
    SystemRoleType queryById(String id)throws Exception;

    @Select("select * from system_role_type")
    List<SystemRoleType> queryListAll()throws Exception;

    @Select(" select a.* from system_role_type as a inner join party_role_type as b on a.id = b.role_Type_Id where b.party_Type=#{partyType}")
    List<SystemRoleType> queryByPartyType(String partyType)throws Exception;

}
